package com.cabrida.livestar.message;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cabrida.livestar.R;
import com.cabrida.livestar.model.BulletinData;

/**
 * 公告adapter
 * 
 * @author why
 * 
 */
public class NoticeAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	private ArrayList<BulletinData> data_list = new ArrayList<BulletinData>();

	public NoticeAdapter(Context context) {
		this.mInflater = LayoutInflater.from(context);
	}

	public void setData(ArrayList<BulletinData> data) {
		data_list = data;
	}

	@Override
	public int getCount() {
		return data_list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return data_list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder = null;
		if (convertView == null) {

			holder = new ViewHolder();

			convertView = mInflater.inflate(
					R.layout.adapter_notice_lv_item, null);
			holder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
			holder.tv_content = (TextView) convertView.findViewById(R.id.tv_content);
			convertView.setTag(holder);

		} else {
			holder = (ViewHolder) convertView.getTag();

		}
		holder.tv_time.setText(data_list.get(position).getB_lasttime());
		holder.tv_content.setText(data_list.get(position).getB_description());

		return convertView;
	}

	class ViewHolder {
		private TextView tv_time;
		private TextView tv_content;
	}

}
